// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Snapshot
{
	public sealed class SnapshotCreateRepositoryRequestParameters : RequestParameters<SnapshotCreateRepositoryRequestParameters>
	{
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("master_timeout"); set => Q("master_timeout", value); }

		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

		[JsonIgnore]
		public bool? Verify { get => Q<bool?>("verify"); set => Q("verify", value); }
	}

	public sealed partial class SnapshotCreateRepositoryRequest : PlainRequestBase<SnapshotCreateRepositoryRequestParameters>
	{
		public SnapshotCreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name repository) : base(r => r.Required("repository", repository))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotCreateRepository;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("master_timeout"); set => Q("master_timeout", value); }

		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

		[JsonIgnore]
		public bool? Verify { get => Q<bool?>("verify"); set => Q("verify", value); }

		[JsonInclude]
		[JsonPropertyName("type")]
		public string Type { get; set; }

		[JsonInclude]
		[JsonPropertyName("settings")]
		public Elastic.Clients.Elasticsearch.Snapshot.RepositorySettings Settings { get; set; }
	}

	public sealed partial class SnapshotCreateRepositoryRequestDescriptor : RequestDescriptorBase<SnapshotCreateRepositoryRequestDescriptor, SnapshotCreateRepositoryRequestParameters>
	{
		internal SnapshotCreateRepositoryRequestDescriptor(Action<SnapshotCreateRepositoryRequestDescriptor> configure) => configure.Invoke(this);
		public SnapshotCreateRepositoryRequestDescriptor(Elastic.Clients.Elasticsearch.Name repository) : base(r => r.Required("repository", repository))
		{
		}

		internal SnapshotCreateRepositoryRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.SnapshotCreateRepository;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		public SnapshotCreateRepositoryRequestDescriptor MasterTimeout(Elastic.Clients.Elasticsearch.Duration? masterTimeout) => Qs("master_timeout", masterTimeout);
		public SnapshotCreateRepositoryRequestDescriptor Timeout(Elastic.Clients.Elasticsearch.Duration? timeout) => Qs("timeout", timeout);
		public SnapshotCreateRepositoryRequestDescriptor Verify(bool? verify = true) => Qs("verify", verify);
		public SnapshotCreateRepositoryRequestDescriptor Repository(Elastic.Clients.Elasticsearch.Name repository)
		{
			RouteValues.Required("repository", repository);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.Snapshot.RepositorySettings SettingsValue { get; set; }

		private RepositorySettingsDescriptor SettingsDescriptor { get; set; }

		private Action<RepositorySettingsDescriptor> SettingsDescriptorAction { get; set; }

		private string TypeValue { get; set; }

		public SnapshotCreateRepositoryRequestDescriptor Settings(Elastic.Clients.Elasticsearch.Snapshot.RepositorySettings settings)
		{
			SettingsDescriptor = null;
			SettingsDescriptorAction = null;
			SettingsValue = settings;
			return Self;
		}

		public SnapshotCreateRepositoryRequestDescriptor Settings(RepositorySettingsDescriptor descriptor)
		{
			SettingsValue = null;
			SettingsDescriptorAction = null;
			SettingsDescriptor = descriptor;
			return Self;
		}

		public SnapshotCreateRepositoryRequestDescriptor Settings(Action<RepositorySettingsDescriptor> configure)
		{
			SettingsValue = null;
			SettingsDescriptor = null;
			SettingsDescriptorAction = configure;
			return Self;
		}

		public SnapshotCreateRepositoryRequestDescriptor Type(string type)
		{
			TypeValue = type;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (SettingsDescriptor is not null)
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, SettingsDescriptor, options);
			}
			else if (SettingsDescriptorAction is not null)
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, new RepositorySettingsDescriptor(SettingsDescriptorAction), options);
			}
			else
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, SettingsValue, options);
			}

			writer.WritePropertyName("type");
			writer.WriteStringValue(TypeValue);
			writer.WriteEndObject();
		}
	}
}